import request from '@/utils/request'
export default class index {
  static getRoles() {
    return request({
      url: 'api/getAllRole',
      method: 'get'
    })
  }
  
  static getRolesList(data: { page: number; limit: number }) {
    return request({
      url: 'api/roles',
      method: 'get',
      params: data
    })
  }
  
  static getRole(id: any) {
    return request({
      url: `api/roles/${id}`,
      method: 'get'
    })
  }
  
  static deleteRole(id: any) {
    return request({
      url: `api/roles/${id}`,
      method: 'delete'
    })
  }
  
  static addRole(data: { id: string; name: string; desc: string }) {
    return request({
      url: 'api/roles',
      method: 'post',
      data
    })
  }
  
  static updatePermission(data: { role_id: number; permission: never[] }) {
    return request({
      url: 'api/roles/permission',
      method: 'post',
      data
    })
  }
  
  static updateRole(key: string, data: { id: string; name: string; desc: string }) {
    return request({
      url: `api/roles/${key}`,
      method: 'put',
      data
    })
  }
}

